#include<bits/stdc++.h>
using namespace std;
#define int long long
struct car{
  int d,v,a;
}c[1000005];
struct over{
  int l,r;
}w[1000005];
bool cmp(over x,over y){
  if(x.l!=y.l)return x.l<y.l;
  return x.r<y.r;
}
int n,p[1000005],L,V,m,t;
bool check(int kd,car x){
    int D=p[kd]-x.d;
    double all=x.v*1.0*x.v+2.0*x.a*D*1.0;
    return all>V*1.0*V;
}
signed main(){
  freopen("detect.in","r",stdin);
  freopen("detect.out","w",stdout);
  scanf("%lld",&t);
  while(t--){
    int wt=0;
    scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld%lld",&c[i].d,&c[i].v,&c[i].a);
    }
    for(int i=1;i<=m;i++)scanf("%lld",&p[i]);
    for(int i=1;i<=n;i++){
      if(c[i].a==0){
        int id=lower_bound(p+1,p+1+m,c[i].d)-p;
        if(c[i].v>V&&id<=m)w[++wt]={id,m};
      }
      else if(c[i].a>0){
        int id=lower_bound(p+1,p+1+m,c[i].d)-p;
        int l=id,r=m,mid=0,ans=m+1;
        while(l<=r){
            mid=(l+r)/2;
            if(check(mid,c[i])){// c[i]  over on mid
                ans=mid;r=mid-1;
            }
            else l=mid+1;
        }
        if(ans<=m)w[++wt]={ans,m};
      }
      else{
        int id=lower_bound(p+1,p+1+m,c[i].d)-p;
        if(!check(id,c[i]))continue;// will never over
        int l=id,r=m,mid=0,ans=id;
        while(l<=r){
            mid=(l+r)/2;
            if(check(mid,c[i])){// c[i]  over on mid
                ans=mid;l=mid+1;
            }
            else r=mid-1;
        }
        if(ans>=id)w[++wt]={id,ans};
      }
    }
    sort(w+1,w+1+wt,cmp);
    //for(int i=1;i<=wt;i++)cout<<w[i].l<<' '<<w[i].r<<endl;
    int nl=w[1].l,nr=w[1].r,sum=0;
    for(int i=2;i<=wt;i++){
        if(w[i].l<=nr){
            nr=min(nr,w[i].r);
            nl=max(nl,w[i].l);
        }
        else{
          sum++;
          nl=w[i].l,nr=w[i].r;
        }
    }
    if(wt!=0)sum++;
    printf("%lld ",wt);
    printf("%lld\n",m-sum);
    for(int i=1;i<=m;i++)p[i]=0;
    for(int i=1;i<=wt;i++)w[i]={0,0};
    for(int i=1;i<=n;i++)c[i]={0,0,0};
    L=V=n=m=0;
  }
  return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
